import { View, Image, Button, Input } from '@tarojs/components'
import { useLoad } from '@tarojs/taro'
import './my.scss'
import { useState } from 'react'

export default function Index() {
  const [avatar, setAvatar] = useState('https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0')
  useLoad(() => {
    console.log('Page loaded.')
  })

  const onChooseAvatar = (e) => {
    const { avatarUrl } = e.detail
    setAvatar(avatarUrl)
  }

  return (
    <View className='index'>
      <Button class="avatar-wrapper" open-type="chooseAvatar" onChooseavatar={onChooseAvatar}>
        <Image class="avatar" src={avatar}></Image>
      </Button>
      <Input type="nickname" class="weui-input" placeholder="请输入昵称" />
    </View>
  )
}
